import { Tree, pageResData } from "@/api/interface/index";
import { PORT1, TreePort } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取植树列表
export const getTreeList = (params: Tree.ReqTreeParams) => {
  console.log(params, "params");
  const { page, pageSize, ...otherParams } = params;
  return http.post<pageResData<Tree.ResTreeList>>(TreePort + `/planting-tree/pageList`, {
    page: page,
    pageSize: pageSize,
    search_key: {
      ...otherParams
      // name: params.name,
      // status: params.status,
      // memo: params.memo,
      // sort: params.sort,
      // created_at: params.created_at,
      // updated_at: params.updated_at
    }
  });
};

// // 获取树形用户列表
// export const getUserTreeList = (params: Tree.ReqUserParams) => {
//   return http.post<ResPage<Tree.ResAreaList>>(PORT1 + `/Tree/tree/list`, params);
// };

// 新增区域
export const addTree = (params: { id: string }) => {
  return http.post(TreePort + `/planting-tree/add`, params);
};

// 编辑区域
export const editTree = (params: { id: string }) => {
  return http.post(TreePort + `/planting-tree/update`, params);
};

// 删除用户
export const deleteUser = (params: { id: string[] }) => {
  return http.post(PORT1 + `/Tree/delete`, params);
};
// 删除区域
export const deleteTree = (params: { id: string[] }) => {
  return http.post(TreePort + `/planting-tree/delete`, params);
};

// 切换用户状态
export const changeUserStatus = (params: { id: string; status: number }) => {
  return http.post(PORT1 + `/Tree/change`, params);
};
